home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / forth / amiga / amigaker.arc / 19.extend < prev    next >
Text File  |  1987-12-30  |  14KB  |  387 lines

  1. ;
  2. ;  19.extend
  3. ;
  4. ;  extend the system
  5.  
  6. * depth           (s -- n ) Returns the number of parameters on the stack.
  7.                   dc.w     -1
  8.                   dc.l     link0
  9. link0             set      *-4
  10.                   dc.b     $85,'dept',$80!'h'
  11.                   cnop     0,2
  12. _depth            dc.l     nest
  13.                   dc.l     _sp_fetch,_sp0,_fetch,_swap,_minus
  14.                   dc.l     _4,_divide,_exit
  15.  
  16. * .s              (s -- )  Displays contents of the parameter stack
  17.                   dc.w     -1
  18.                   dc.l     link2
  19. link2             set      *-4
  20.                   dc.b     $82,'.',$80!'s'
  21.                   cnop     0,2
  22. _dot_s            dc.l     nest
  23.                   dc.l     _depth,_question_dup,_question_branch,3$
  24.                   dc.l     _0,_nest_do,2$
  25. 1$                dc.l       _depth,_i,_minus,_1_minus,_pick
  26.                   dc.l       _nest_lit,10,_u_dot_r,_space
  27.                   dc.l       _key_question,_nest_question_leave
  28.                   dc.l     _nest_loop,1$
  29. 2$                dc.l     _branch,4$
  30. 3$                dc.l     _nest_dot_quote
  31.                   dc.b     7,'Empty ',0
  32.                   cnop     0,2
  33. 4$                dc.l     _exit
  34.  
  35. * (.id)           (s addr len -- addr' len ) Moves the id to stdbuffer
  36. ; and pads it with underlines.
  37.                   dc.w     -1
  38.                   dc.l     link0
  39. link0             set      *-4
  40.                   dc.b     $85,'(.id',$80!')'
  41.                   cnop     0,2
  42. _nest_dot_id      dc.l     *+4
  43.                   move.l   (sp),d0           ;get length
  44.                   beq.s    4$                ;exit if it's null
  45.                   subq     #1,d0             ;adjust for the loop
  46.                   lea      stdbuffer,a0      ;destination
  47.                   move.l   4(sp),a1          ;source
  48.                   move.l   a0,4(sp)          ; alter string addr
  49. 1$                move.b   (a1)+,(a0)+       ;move name
  50.                   dbmi     d0,1$             ; until high bit or 31 max.
  51.                   subq.l   #1,a0             ;point to last char
  52.                   moveq    #127,d1           ;mask
  53.                   and.b    d1,(a0)+          ; of high bit
  54.                   moveq    #'_',d1           ;set underline character
  55.                   addq.b   #1,d0             ;adjust for loop
  56.                   bra.s    3$
  57. 2$                move.b   d1,(a0)+          ;pad with underscore
  58. 3$                dbra     d0,2$
  59. 4$                jmp      (a3)
  60.  
  61.  
  62. * .id             (s nfa -- )  Prints the name of the word on the terminal.
  63.                   dc.w     -1
  64.                   dc.l     link2
  65. link2             set      *-4
  66.                   dc.b     $83,'.i',$80!'d'
  67.                   cnop     0,2
  68. _dot_id           dc.l     nest
  69.                   dc.l     _count,_nest_lit,31,_and
  70.                   dc.l     _nest_dot_id,_type,_space,_exit
  71.  
  72. * c/l             Constant, starts out at 79 for a full screen. If resized,
  73. ; windowstatus can update the sizes
  74.                   dc.w     -1
  75.                   dc.l     link3
  76. link3             set      *-4
  77.                   dc.b     $83,'c/',$80!'l'
  78.                   cnop     0,2
  79. _c_per_l          dc.l     doconstant,79
  80.  
  81. * l/scr           Constant, 22 lines at the start. Resizing will alter it.
  82.                   dc.w     -1
  83.                   dc.l     link0
  84. link0             set      *-4
  85.                   dc.b     $85,'l/sc',$80!'r'
  86.                   cnop     0,2
  87. _l_per_scr        dc.l     doconstant,22
  88.  
  89. * \               Comment character, ignores the rest of the line.
  90.                   dc.w     -1
  91.                   dc.l     link0
  92. link0             set      *-4
  93.                   dc.b     $81!immediate,$80!'\'
  94.                   cnop     0,2
  95. _Skip             dc.l     nest
  96.                   dc.l     _end_question,_on,_exit
  97.  
  98. * (s              Synonym for (, used as stack comments.
  99.                   dc.w     -1
  100.                   dc.l     link0
  101. link0             set      *-4
  102.                   dc.b     $82!immediate,'(',$80!'s'
  103.                   cnop     0,2
  104. _paren_s          dc.l     nest
  105.                   dc.l     _paren
  106.                   dc.l     _exit
  107.  
  108. * ?               (s addr -- ) Prints contents of the cell at addr.
  109.                   dc.w     -1
  110.                   dc.l     link3
  111. link3             set      *-4
  112.                   dc.b     $81,$80!'?'
  113.                   cnop     0,2
  114.                   dc.l     nest
  115.                   dc.l     _fetch,_dot,_exit
  116.  
  117. * ?enough         (S n -- ) Issues an error message if too few parameters
  118. ; are on the parameter stack.
  119.                   dc.w     -1
  120.                   dc.l     link3
  121. link3             set      *-4
  122.                   dc.b     $87,'?enoug',$80!'h'
  123.                   cnop     0,2
  124. _question_enough  dc.l     nest
  125.                   dc.l     _depth,_1_minus,_greater_than
  126.                   dc.l     _nest_abort_quote
  127.                   dc.b     22,'Not enough Parameters',0
  128.                   cnop     0,2
  129.                   dc.l     _exit
  130.  
  131. ; root vocabulary, only and also concept
  132.  
  133. rootlink0         set      0
  134. rootlink1         set      0
  135. rootlink2         set      0
  136. rootlink3         set      0
  137.  
  138. * root            Vocabulary root
  139.                   dc.w     -1
  140.                   dc.l     link2
  141. link2             set      *-4
  142.                   dc.b     $84,'roo',$80!'t'
  143.                   cnop     0,2
  144. _root             dc.l     vocabulary_does
  145.                   dc.l     rootLink0,rootLink1,rootLink2,rootLink3
  146.                   dc.l     voc_link
  147. voc_link          set      *-4
  148.  
  149. * also            (s -- )
  150.                   dc.w     -1
  151.                   dc.l     rootlink1
  152. rootlink1         set      *-4
  153.                   dc.b     $84,'als',$80!'o'
  154.                   cnop     0,2
  155.                   dc.l     nest
  156.                   dc.l     _context,_dup,_4_plus,_number_vocs
  157.                   dc.l     _2_minus,_4_times,_cmove_up,_exit
  158.  
  159. * only            (s -- )
  160.                   dc.w     -1
  161.                   dc.l     rootlink3
  162. rootlink3         set      *-4
  163.                   dc.b     $84,'onl',$80!'y'
  164.                   cnop     0,2
  165.                   dc.l     nest
  166.                   dc.l     _nest_lit,_root,_to_body,_context
  167.                   dc.l     _number_vocs,_1_minus,_4_times
  168.                   dc.l     _2dup,_erase,_plus,_store,_root,_exit
  169.  
  170. * previous        (s -- )
  171.                   dc.w     -1
  172.                   dc.l     rootlink0
  173. rootlink0         set      *-4
  174.                   dc.b     $88,'previou',$80!'s'
  175.                   cnop     0,2
  176.                   dc.l     nest
  177.                   dc.l     _context,_dup,_4_plus,_swap,_number_vocs
  178.                   dc.l     _2_minus,_4_times,_cmove
  179.                   dc.l     _context,_number_vocs,_2_minus,_4_times
  180.                   dc.l     _plus,_off,_exit
  181.  
  182. * forth
  183.                   dc.w     -1
  184.                   dc.l     rootlink2
  185. rootlink2         set      *-4
  186.                   dc.b     $85,'fort',$80!'h'
  187.                   cnop     0,2
  188.                   dc.l     nest
  189.                   dc.l     _forth,_exit
  190.  
  191. * definitions
  192.                   dc.w     -1
  193.                   dc.l     rootlink0
  194. rootlink0         set      *-4
  195.                   dc.b     $8B,'definition',$80!'s'
  196.                   cnop     0,2
  197.                   dc.l     nest
  198.                   dc.l     _definitions,_exit
  199.  
  200. * order
  201.                   dc.w     -1
  202.                   dc.l     rootlink3
  203. rootlink3         set      *-4
  204.                   dc.b     $85,'orde',$80!'r'
  205.                   cnop     0,2
  206.                   dc.l     nest
  207.                   dc.l     _cr,_nest_dot_quote
  208.                   dc.b     10,'Context: ',0
  209.                   cnop     0,2
  210.                   dc.l     _context,_number_vocs,_0,_nest_do,3$
  211. 1$                dc.l     _dup,_fetch,_question_dup,_question_branch,2$
  212.                   dc.l     _body_from,_to_name,_dot_id
  213. 2$                dc.l     _4_plus,_nest_loop,1$
  214. 3$                dc.l     _drop
  215.                   dc.l     _cr,_nest_dot_quote
  216.                   dc.b     10,'Current: ',0
  217.                   cnop     0,2
  218.                   dc.l     _current,_fetch,_body_from,_to_name
  219.                   dc.l     _dot_id,_exit
  220.  
  221. * vocs
  222.                   dc.w     -1
  223.                   dc.l     rootlink2
  224. rootlink2         set      *-4
  225.                   dc.b     $84,'voc',$80!'s'
  226.                   cnop     0,2
  227.                   dc.l     nest
  228.                   dc.l     _voc_link
  229. 1$                dc.l     _fetch,_question_dup,_question_branch,2$
  230.                   dc.l     _dup,_number_threads,_4_times,_minus
  231.                   dc.l     _body_from,_to_name,_dot_id,_branch,1$
  232. 2$                dc.l     _exit
  233.  
  234.  
  235. ; additional comparisons
  236.  
  237. * u<=
  238.                   dc.w     -1
  239.                   dc.l     link1
  240. link1             set      *-4
  241.                   dc.b     $83,'u<',$80!'='
  242.                   cnop     0,2
  243.                   dc.l     nest
  244.                   dc.l     _u_greater,_not,_exit
  245.  
  246. * u>=
  247.                   dc.w     -1
  248.                   dc.l     link1
  249. link1             set      *-4
  250.                   dc.b     $83,'u>',$80!'='
  251.                   cnop     0,2
  252.                   dc.l     nest
  253.                   dc.l     _u_less,_not,_exit
  254.  
  255. * <=
  256.                   dc.w     -1
  257.                   dc.l     link0
  258. link0             set      *-4
  259.                   dc.b     $82,'<',$80!'='
  260.                   cnop     0,2
  261.                   dc.l     nest
  262.                   dc.l     _greater_than,_not,_exit
  263.  
  264. * >=
  265.                   dc.w     -1
  266.                   dc.l     link2
  267. link2             set      *-4
  268.                   dc.b     $82,'>',$80!'='
  269.                   cnop     0,2
  270.                   dc.l     nest
  271.                   dc.l     _less_than,_not,_exit
  272.  
  273. * 0<=
  274.                   dc.w     -1
  275.                   dc.l     link0
  276. link0             set      *-4
  277.                   dc.b     $83,'0<',$80!'='
  278.                   cnop     0,2
  279.                   dc.l     nest
  280.                   dc.l     _0_greater,_not,_exit
  281.  
  282. * 0>=
  283.                   dc.w     -1
  284.                   dc.l     link0
  285. link0             set      *-4
  286.                   dc.b     $83,'0>',$80!'='
  287.                   cnop     0,2
  288.                   dc.l     nest
  289.                   dc.l     _0_less,_not,_exit
  290.  
  291. ; display words in the dictionary
  292.  
  293. * ?line
  294.                   dc.w     -1
  295.                   dc.l     link3
  296. link3             set      *-4
  297.                   dc.b     $85,'?lin',$80!'e'
  298.                   cnop     0,2
  299. _question_line    dc.l     nest
  300.                   dc.l     _number_out,_fetch,_plus
  301.                   dc.l     _c_per_l,_8_minus,_greater_than
  302.                   dc.l     _question_branch,1$
  303.                   dc.l     _cr
  304. 1$                dc.l     _exit
  305.  
  306.  
  307. * largest         (s addr n -- addr' val )
  308.                   dc.w     -1
  309.                   dc.l     link0
  310. link0             set      *-4
  311.                   dc.b     $87,'larges',$80!'t'
  312.                   cnop     0,2
  313. _largest          dc.l     nest
  314.                   dc.l     _over,_0,_swap,_rot,_0
  315.                   dc.l     _nest_do,3$
  316. 1$                dc.l     _2dup,_fetch,_u_less,_question_branch,2$
  317.                   dc.l     _minus_rot,_2drop,_dup,_fetch,_over
  318. 2$                dc.l     _4_plus,_nest_loop,1$
  319. 3$                dc.l     _drop,_exit
  320.  
  321. * words
  322.                   dc.w     -1
  323.                   dc.l     link3
  324. link3             set      *-4
  325.                   dc.b     $85,'word',$80!'s'
  326.                   cnop     0,2
  327. _words            dc.l     nest
  328.                   dc.l     _cr,_context,_fetch,_here,_number_threads
  329.                   dc.l     _4_times,_cmove
  330. 1$                dc.l     _here,_number_threads,_largest,_dup
  331.                   dc.l     _question_branch,3$
  332.                   dc.l     _dup,_l_to_name,_dup,_c_fetch,_nest_lit,31
  333.                   dc.l     _and,_question_line,_dot_id,_space,_space
  334.                   dc.l     _fetch,_swap,_store,_key_question
  335.                   dc.l     _question_branch,2$
  336.                   dc.l     _exit
  337. 2$                dc.l     _branch,1$
  338. 3$                dc.l     _2drop,_exit
  339.  
  340. * words  ( for the root vocabulary )
  341.                   dc.w     -1
  342.                   dc.l     rootlink3
  343. rootlink3         set      *-4
  344.                   dc.b     $85,'word',$80!'s'
  345.                   cnop     0,2
  346.                   dc.l     nest
  347.                   dc.l     _words,_exit
  348.  
  349. ; two words to show the linked lists, one for files and one for libraries.
  350.  
  351. * files
  352.                   dc.w     -1
  353.                   dc.l     link2
  354. link2             set      *-4
  355.                   dc.b     $85,'file',$80!'s'
  356.                   cnop     0,2
  357.                   dc.l     nest
  358.                   dc.l     _cr,_file_link
  359. 1$                dc.l     _fetch,_question_dup,_question_branch,4$
  360.                   dc.l     _dup,_4_plus,_count,_type
  361.                   dc.l     _dup,_nest_lit,18,_minus,_fetch
  362.                   dc.l     _question_branch,2$
  363.                   dc.l     _nest_dot_quote
  364.                   dc.b     8,' (open)',0
  365.                   cnop     0,2
  366.                   dc.l     _branch,3$
  367. 2$                dc.l     _nest_dot_quote
  368.                   dc.b     10,' (closed)',0
  369.                   cnop     0,2
  370. 3$                dc.l     _cr,_branch,1$
  371. 4$                dc.l     _exit
  372.  
  373. * libs
  374.                   dc.w     -1
  375.                   dc.l     link0
  376. link0             set      *-4
  377.                   dc.b     $84,'lib',$80!'s'
  378.                   cnop     0,2
  379.                   dc.l     nest
  380.                   dc.l     _cr,_lib_link
  381. 1$                dc.l     _fetch,_question_dup,_question_branch,2$
  382.                   dc.l     _dup,_8_minus,_to_name,_dot_id,_cr
  383.                   dc.l     _branch,1$
  384. 2$                dc.l     _exit
  385.  
  386.  
  387.